package com.carbon.carbonmanager.controller;

import com.carbon.carbonmanager.model.UserInfo;
import com.carbon.carbonmanager.service.UserService;
import com.carbon.carbonmanager.unit.Pager;
import com.carbon.carbonmanager.unit.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户模块请求API
 * */
@RestController
@CrossOrigin
public class UserController {
    @Autowired
    UserService userService;
    /**
     * 查询所有用户信息API
     * */
    @ResponseBody
    @RequestMapping(value = "/getalluser", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response getallusers(){
        return userService.getAllUser();
    }

    /**
     * 查询所有用户信息，分页数据
     * @return pagerData和pagerTotal
     * */
    @ResponseBody
    @RequestMapping(value = "/getAllUserPagerData", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response getAllUserPagerData(@RequestBody Pager pager){
        return userService.getAllUserPagerData(pager);
    }

    /**
     * 获取用户角色列表
     * */
    @ResponseBody
    @RequestMapping(value = "/getUserRoleList", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response getUserRoleList(){
        return userService.getUserRoleList();
    }

    /**
     * 获取用户企业类型
     * getUserClassList
     * */
    @ResponseBody
    @RequestMapping(value = "/getUserClassList", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response getUserClassList(){
        return userService.getUserClassList();
    }

    /**
     * 根据用户id修改用户角色信息
     * */
    @ResponseBody
    @RequestMapping(value = "/updateUserRoleByUserId", method = RequestMethod.POST, produces = "application/json; utf-8")
    public Response updateUserRoleByUserId(@RequestBody UserInfo userInfo){
        return userService.updateUserRoleByUserId(userInfo);
    }
}
